Skip to content

Conversation

SparrowLii
Copy link
Contributor

@SparrowLii SparrowLii commented May 21, 2021

Update #969
Four functions are implemented for ArrayView<MathCell, _> in impl_methods.rs:
zip_cell_with, zip_cell_with_elem, zip_cell_with_same_shape, zip_cell_with_by_rows.
Operator overloading is implemented in impl_ops.rs for the following situations:
ArrayView<MathCell, _> binary_op &ArrayBase
ArrayView<MathCell, _> binary_op Scalar
ArrayView<MathCell, _> assign_op &ArrayBase
ArrayView<MathCell, _> assign_op Scalar

The unresolved problems are:

  1. Currently MathCell can only be left value. The main reason are:
    (1) Conflicts occur when compiling MathCell<A> op MathCell<B>
    (2) Rust's orphan rules. We can't write code like this:impl<T> Add<MathCell<T>> for T. This will cause E0210 error

  2. The value in MathCell must be Copy
    This is because the value in MathCell needs to be retrieved using the get() method. We cannot get &T from &MathCell<T> unless we create a new structure MathRefCell(RefCell<T>)

@bluss
Copy link
Member

bluss commented May 21, 2021

We don't implement ArrayViewMut + x (only ArrayViewMut += x), and this should be the same way IMO. I.e we want the += and similar ops. I hope we can do with without adding new copies like all the new .zip* methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants